import 'package:amway_superapp_creator_plugin/config/creater_init_config.dart';
import 'package:amway_superapp_creator_plugin/dialog/comm_tip_dialog.dart';
import 'package:amway_superapp_creator_plugin/routers/application.dart';
import 'package:amway_superapp_creator_plugin/routers/routes.dart';
import 'package:amway_superapp_creator_plugin/utils/log_util.dart';
import 'package:amway_superapp_creator_plugin/utils/toast_util.dart';
import 'package:amway_superapp_creator_plugin/views/create_launch_view.dart';
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
  TextEditingController phoneController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    CreateInitConfig.initCofig(context: context);
    return Scaffold(
        appBar: AppBar(
          title: Text('測試頁面'),
        ),
        body: SingleChildScrollView(
          child: Container(
              child: Column(
            children: [
              Container(
                child: TextField(
                  controller: phoneController,
                  keyboardType: TextInputType.text,
                  decoration: InputDecoration(
                    contentPadding: EdgeInsets.all(10.0),
                    icon: Icon(Icons.text_fields),
                    labelText: '请输入adaId)',
                    helperText: '请输入你的安利号',
                  ),
                ),
              ),
              Center(
                child: MaterialButton(
                    child: Text('进入创玩小站'),
                    color: Colors.blue,
                    onPressed: () {
                      if (phoneController.text == null ||
                          phoneController.text.isEmpty) {
                        ToastUtils.showLongToast('ADA号为空');
                        return;
                      }
                      Map<String, dynamic> parameters = {
                        'amwayAda': phoneController.text,
                      };
                      Application.router.navigateTo(
                        context,
                        Routes.root,
                        routeSettings: RouteSettings(arguments: parameters),
                      );
                    }),
              ),
              Center(
                child: MaterialButton(
                  child: Text('测试provide'),
                  color: Colors.blue,
                  onPressed: () {
                    //Application.router.navigateTo(context, Routes.testprovide);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('测试provide1'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.testprovide1);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('图片选择'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.testselphoto);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('修改主题'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.changeTheme);
                  },
                ),
              ),
              //121209
              Container(
                margin: EdgeInsets.all(10),
                child: CreateLaunchView(
                  amwayAda: "363333",
                  amwayId: "36099966991199924101",
                  phone: '18665620749',
                  token: "1234",
                 optionCallback: (data){
                  LogUtil.e(data);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('模块设置'),
                  color: Colors.blue,
                  onPressed: () {
                    Map<String, dynamic> parameters = {
                      'amwayAda': "ada",
                      'amwayId': "a1234",
                    };
                    Application.router.navigateTo(context, Routes.mainSettings,
                        routeSettings: RouteSettings(arguments: parameters));
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('身份列表'),
                  color: Colors.blue,
                  onPressed: () {

                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('兴趣列表'),
                  color: Colors.blue,
                  onPressed: () {
                    // Application.router.navigateTo(
                    //   context,
                    //   Routes.tagList,
                    // );
                    Routes.navigateTo(context, Routes.tagList, params: {
                      'pageType': ''
                          '1'
                    });
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('用户头像'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.userIcon);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('好物推荐'),
                  color: Colors.blue,
                  onPressed: () {
                    Map<String, dynamic> parameters = {
                      'amwayAda': "ada",
                      'amwayId': "a1234",
                    };
                    Application.router
                        .navigateTo(context, Routes.recommendProduct,routeSettings: RouteSettings(arguments: parameters));
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('设置封面'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router
                        .navigateTo(context, Routes.setUserCover)
                        .then((value) => print(value));
                  },
                ),
              ),
              Center(
                  child: MaterialButton(
                      child: Text('编辑资料'),
                      color: Colors.blue,
                      onPressed: () {
                        Application.router.navigateTo(context, Routes.editdata);
                      })),
              Center(
                child: MaterialButton(
                  child: Text('精选组合'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router
                        .navigateTo(context, Routes.selectedcombination);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('我的圈子'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.mycircle);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('接口测试'),
                  color: Colors.blue,
                  onPressed: () {
                    // test();
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('圈子详情视频'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router
                        .navigateTo(context, Routes.MYCIRCLEDETAILSVIDEO);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('圈子详情图片'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router
                        .navigateTo(context, Routes.MYCIRCLEDETAILSIMAGES);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('Reorderable测试'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.testPage);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('发布圈子'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.SENDCIRCLE);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('相机测试1'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.CAMERA_TEST);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('相机测试2'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.CAMERA_PAGE);
                  },
                ),
              ),
              Center(
                child: MaterialButton(
                  child: Text('重新编写圈子'),
                  color: Colors.blue,
                  onPressed: () {
                    Application.router.navigateTo(context, Routes.SENDEDITERPAGE);
                  },
                ),
              ),

              Center(
                child: MaterialButton(
                  child: Text('测试跳转html数据'),
                  color: Colors.blue,
                  onPressed: () {
                    Map<String,dynamic>parameters={};
                    parameters['dataHtml']='<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>文档标题</title></head> <body>文档内容......</body></html>';
                    Application.router.navigateTo(context, Routes.GUIDEDETAILS,routeSettings: RouteSettings(arguments: parameters));
                  },
                ),
              ),

              Center(
                child: MaterialButton(
                  child: Text('dialogtest'),
                  color: Colors.blue,
                  onPressed: () {
                    showDialog(
                      context: context,
                      builder: (context) => CommTipDialog(
                        content: '返回上一步会丢失当前信息，是否返回？',
                        confirmText: "确认",
                        closeText: "取消",
                        confirmCallback: () {
                        },
                        dismissCallback: () {
                        },
                      ),
                    );
                  },
                ),
              ),
            ],
          )),
        ));
  }
}
